package game.Screens;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;

import game.ActionListener;
import game.Game;
import game.LevelManager;
import game.Config.Config;
import game.Config.Config.GameInput;
import game.Menus.TextMenuItem;
import game.Menus.VerticalMenu;

/**
 * This is the screen where the player can choose diffuculty.
 * @author Victor
 *
 */
public class DifficultyScreen extends Screen{
	VerticalMenu menu = new VerticalMenu(0,Config.MAIN_MENU_GAP);
	/**
	 * Initialzes the screen.
	 */
	@Override
	public void begin() {
		menu.addItem(new TextMenuItem("Easy - "+Config.EASY_AMOUNT + " eggs",new ActionListener() {
			@Override
			public void action() {
				startGame(Config.EASY_AMOUNT);
			}
		}));
		menu.addItem(new TextMenuItem("Medium - "+Config.MEDIUM_AMOUNT+" eggs", new ActionListener() {
			@Override
			public void action() {
				startGame(Config.MEDIUM_AMOUNT);
			}
		}));
		menu.addItem(new TextMenuItem("Hard - "+Config.HARD_AMOUNT+" eggs", new ActionListener() {
			@Override
			public void action() {
				startGame(Config.HARD_AMOUNT);
			}
		}));
		menu.addItem(new TextMenuItem("Egg-hard - "+Config.EGGHARD_AMOUNT+" eggs", new ActionListener() {
			@Override
			public void action() {
				startGame(Config.EGGHARD_AMOUNT);
			}
		}));
	}

	/**
	 * Starts the game with a given difficulty.
	 * @param difficulty
	 */
	protected void startGame(int difficulty) {
		LevelManager.setDifficulty(difficulty);
		Game.screenStack.pop();//Remove itself
		Game.pushNewScreen(new GameScreen());
	}

	@Override
	public void end() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void update(GameContainer gc, int delta) {
		// TODO Auto-generated method stub
		
	}

	/**
	 * Draws the screen.
	 */
	@Override
	public void draw(Graphics graphic) {
		graphic.drawString("Choose how many eggs you have to protect(Difficulty)", Config.DIFFICULTY_POSITION.x, Config.DIFFICULTY_POSITION.y);
		menu.draw(Config.DIFFICULTY_MENU_POSITION.copy(), graphic);
		
	}

	/**
	 * Check all the new input presses.
	 */
	@Override
	public void inputPressed(GameInput input) {
		if(input == GameInput.UP){
			menu.up();
		}
		if(input == GameInput.DOWN){
			menu.down();
		}
		if(input == GameInput.ACTION){
			menu.press();
		}
		
	}

	@Override
	public void inputDown(GameInput input) {
		// TODO Auto-generated method stub
		
	}
	
		

}
